<template>
 <h1>双向绑定练习</h1>
<!--  用户信息收集-->
<!-- v-model:双向绑定 -->
  <h2>用户信息收集</h2>
  <input type="text" placeholder="请输入用户名" v-model="user.username"> <br/>
  <input type="password" placeholder="请输入密码" v-model="user.password"><br/>
  <input type="text" placeholder="请输入年龄" v-model="user.age"><br/>
  性别 <br/>
  <input type="radio" name="gender" value="1" v-model="user.gender"> 男
  <input type="radio" name="gender" value="2" v-model="user.gender"> 女
  <input type="radio" name="gender" value="3" v-model="user.gender"> 未知

  <br/>
<!--事件绑定  -->
  <button @click="fun()">注册</button> <br/>
<!-- v-on:click -->
  <button v-on:click="fun()">注册2</button> <br/>
<!-- 回车按下事件 -->
  <input type="text" @keydown.enter="fun()">
</template>

<script setup>
// {
//   username:"张三",
//   password: "123456"
// }
import {ref} from "vue";

const user = ref({
  username:"张三",
  password:"123456",
  age:"18",
  gender:"1"
})
const fun=()=>{
  console.log(user.value)
}
</script>

<style scoped>

</style>